#include<bits/stdc++.h>
#define ll long long
#define int ll
#define L x<<1
#define R L|1
#define mid (l+r>>1)
#define lc L,l,mid
#define rc R,mid+1,r
#define OK y^fa&&!vis[y]
#define Root 1,1,n
#define rep(x,y,z) for(int x=(y);x<=(z);x++)
#define per(x,y,z) for(int x=(y);x>=(z);x--)
#define repn(x) rep(x,1,n)
#define repm(x) rep(x,1,m)
#define pb push_back
#define e(x) for(int i=h[x],y=to[i];i;i=nxt[i],y=to[i])
#define E(x) for(auto y:p[x])
#define Pi pair<int,int>
#define ui unsigned ll
inline int read(){int s=0,w=1;char c=getchar();while(c<48||c>57) {if(c=='-') w=-1;c=getchar();}while(c>=48&&c<=57)s=(s<<1)+(s<<3)+c-48,c=getchar();return s*w;}
inline void pf(ll x){if(x<0) putchar('-'),x=-x;if(x>9)pf(x/10);putchar(x%10+48);}
using namespace std;
const int N =2e5+5,M=1e6+5,inf=(1LL<<30)-1,mod=998244853;
const ll llf=1e18;
inline void add(int &a,int b){((a+=b)>=mod) and (a-=mod);}
inline int Add(int a,int b){return add(a,b),a;}
inline int mul(int a,int b){return 1LL*a*b%mod;}
inline void Mul(int &a,int b){a=mul(a,b);}
inline void red(int &a,int b){add(a,mod-b);}
inline int Red(int a,int b){return red(a,b),a;}
inline int qp(int a,int b){if(!b)return 1;int c=qp(a,b>>1);Mul(c,c);if(b&1)Mul(c,a);return c;}
inline int INV(int x){return qp(x,mod-2);}
const int base=13331;
int n,m,h[N];
int lg[N],st[N][20][2],sp[N][20];
inline int get(int l,int r,int ty){
	int p=lg[r-l+1];
	return max(st[l][p][ty],st[r-(1<<p)+1][p][ty]);
}
inline int getp(int l,int r){
	int p=lg[r-l+1],a=sp[l][p],b=sp[r-(1<<p)+1][p];
	return h[a]>h[b]?a:b;
}
inline int distu(int x,int y,int X,int Y){
	int dx=abs(x-X),dy=abs(y-Y);
	return dy*4+max(0LL,dx-dy)*2;
}
inline int distd(int x,int y,int X,int Y){
	int dx=abs(x-X),dy=abs(y-Y);
	return dy+max(0LL,dx-dy)*2;
}
signed main(){
	n=read(),m=read(),lg[0]=-1;
	repn(i)h[i]=read(),lg[i]=lg[i>>1]+1,st[i][0][0]=h[i]-i,st[i][0][1]=h[i]+i,sp[i][0]=i;
	rep(p,1,18)rep(i,1,n-(1<<p)+1)st[i][p][0]=max(st[i][p-1][0],st[i+(1<<p-1)][p-1][0]),st[i][p][1]=max(st[i][p-1][1],st[i+(1<<p-1)][p-1][1]),sp[i][p]=h[sp[i][p-1]]>h[sp[i+(1<<p-1)][p-1]]?sp[i][p-1]:sp[i+(1<<p-1)][p-1];
	repm(i){
		int s=read(),t=read();
		if(s==t)puts("0");
		else if(s<t){
			int mp=getp(s,t),Mxl=get(s,mp,0),Mxr=get(mp,t,1),ans=(Mxl-(h[s]-s))*4+(Mxr-(h[t]+t))*1;
			ans+=distu(s,s+Mxl,mp,h[mp])+distd(mp,h[mp],t,Mxr-t);
			cout <<ans<<'\n';
		}
		else {
			int mp=getp(t,s),Mxl=get(t,mp,0),Mxr=get(mp,s,1),ans=(Mxr-(h[s]+s))*4+(Mxl-(h[t]-t))*1;
			ans+=distu(s,Mxr-s,mp,h[mp])+distd(mp,h[mp],t,t+Mxl);
			cout <<ans<<'\n';
		}
	}
	return 0;
}
